//
//  MainViewController.m
//  test_lv
//
//  Created by nykj-mac-03 on 2017/5/18.
//  Copyright © 2017年 renzhi. All rights reserved.
//
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
//屏幕宽度
#define windowWidth [UIScreen mainScreen].bounds.size.width
//屏幕高度
#define windowHeight [UIScreen mainScreen].bounds.size.height
#import "MainViewController.h"

#import "UIButton+ImageTitleSpacing.h"
#import "UIButton+ImageTitleSpacing.h"

#import "MeViewController.h"
#import "MessageViewController.h"
#import "ContactViewController.h"
#import "OfficeViewController.h"
#import "ContactViewController.h"
#import "ApplyViewController.h"
#import "AddCaseViewController.h"
#import "MyCaseViewController.h"
#import "ApprovalViewController.h"
#import "FinanceViewController.h"
#import "FileViewController.h"
#import "ToolViewController.h"

@interface MainViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *TitleLable;

@property (weak, nonatomic) IBOutlet UILabel *DetaiLable;
@property (weak, nonatomic) IBOutlet UIButton *leftButton;
@property (weak, nonatomic) IBOutlet UIButton *RightButton;
@property (weak, nonatomic) IBOutlet UIView *ButtonView;


@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//   self.title = @"韦淋律师的 app";
    [self initUI];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.backgroundColor = [UIColor blueColor];
    
    
}
#pragma mark - LifeCircle
//- (void)viewWillAppear:(BOOL)animated{
//    self.navigationController.navigationBarHidden = YES
//    ;
//}
//
//- (void)viewWillDisappear:(BOOL)animated{
//    self.navigationController.navigationBarHidden = NO
//    ;
//}
- (void)initUI{
    [_leftButton setImage:[UIImage imageNamed:@"book"] forState:0];
    [_leftButton setTitle:@"我的案件" forState:0];
    [_leftButton layoutButtonWithEdgInsetsStyle:WxyButtonEdgeInsetsStyleImageTop imageTitleSpacing:5];
    
    [_RightButton setImage:[UIImage imageNamed:@"mess"] forState:0];
    [_RightButton setTitle:@"添加案件" forState:0];
    [_RightButton layoutButtonWithEdgInsetsStyle:WxyButtonEdgeInsetsStyleImageTop imageTitleSpacing:5];
     NSArray *titleArray = @[@"审批",@"财务审批",@"文件",@"消息",@"联系人",@"工具",@"消息",@"联系人",@"工具"];
     NSArray *imageArray = @[@"mess",@"mess",@"book",@"mess",@"mess",@"book",@"mess",@"mess",@"book"];
    CGFloat width = (CGFloat)(windowWidth - 13)/3;
    for (int i = 0; i < titleArray.count; i++) {
        [self.view layoutIfNeeded];
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(3+width*(i%3)+3*(i%3), 3+width*(i/3)+3*(i/3), width, width)];
        button.titleLabel.textColor = [UIColor whiteColor];
        button.backgroundColor = RGBCOLOR(42+i, 155+i, 255);
        [button setTitle:titleArray[i] forState:0];
        [button setImage:[UIImage imageNamed:imageArray[i]] forState:0];
        [button layoutButtonWithEdgInsetsStyle:WxyButtonEdgeInsetsStyleImageTop imageTitleSpacing:10];
        [_ButtonView addSubview:button];
        button.tag = 10+i;
        [button addTarget:self action:@selector(chooseView:) forControlEvents:UIControlEventTouchUpInside];
        NSLog(@"logRect = %@", NSStringFromCGRect(button.frame));
    }
}

- (IBAction)click:(UIButton *)sender {
    if (sender.tag == 1) {
        
     //我的案件
    MyCaseViewController *myCaseVC = [[MyCaseViewController alloc] init];
    [self.navigationController pushViewController:myCaseVC animated:YES];
    
    }else if(sender.tag == 2){
        
    //  添加案件
    AddCaseViewController *addCaseVC = [[AddCaseViewController alloc] init];
    [self.navigationController pushViewController:addCaseVC animated:YES];
        
    }else if (sender.tag == 3){
        
    //选择头像
    MeViewController *meVC = [[MeViewController alloc] init];
    [self.navigationController pushViewController:meVC animated:YES];
    }
}

- (void)chooseView:(UIButton *)sender{
    NSInteger tag = sender.tag;
    if (tag == 10) {
        ApprovalViewController *approvalVC = [[ApprovalViewController alloc] init];
        [self.navigationController pushViewController:approvalVC animated:YES];
    }
    if (tag == 11) {
        FinanceViewController *financelVC = [[FinanceViewController alloc] init];
        [self.navigationController pushViewController:financelVC animated:YES];
    }
    if (tag == 12) {
        FileViewController *fileVC = [[FileViewController alloc] init];
        [self.navigationController pushViewController:fileVC animated:YES];
    }
    if (tag == 13) {
        MessageViewController *messageVC = [[MessageViewController alloc] init];
        [self.navigationController pushViewController:messageVC animated:YES];
    }
    if (tag == 14) {
        ContactViewController *contactVC = [[ContactViewController alloc] init];
        [self.navigationController pushViewController:contactVC animated:YES];
    }
    if (tag == 15) {
        ToolViewController *toolVC = [[ToolViewController alloc] init];
        [self.navigationController pushViewController:toolVC animated:YES];
    }
    if (tag == 16) {
        MessageViewController *messageVC = [[MessageViewController alloc] init];
        [self.navigationController pushViewController:messageVC animated:YES];
    }
    if (tag == 17) {
        ContactViewController *contactVC = [[ContactViewController alloc] init];
        [self.navigationController pushViewController:contactVC animated:YES];
    }
    if (tag == 18) {
        ToolViewController *toolVC = [[ToolViewController alloc] init];
        [self.navigationController pushViewController:toolVC animated:YES];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}



@end
